<template>
  <header class="header header-page-bg">
    <div class="container">
      <div class="header-page-content">
        <div class="row align-items-center">
          <div class="col-md-7">
            <div class="header-content">
              <h1>My Account</h1>
              <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                  <li class="breadcrumb-item active" aria-current="page">
                    My Account
                  </li>
                </ol>
              </nav>
            </div>
          </div>
          <div class="col-md-5 d-none d-md-block">
            <div
              class="header-content-image header-content-abs-image header-content-abs-top"
            >
              <img
                :src="require('assets/images/inner-page-header/page-1.png')"
                alt="page"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>

  <div class="account-page-section pt-100 pb-70">
    <div class="container">
      <div class="row">
        <div class="col-sm-12 col-md-4 col-lg-4 pb-30">
          <div class="account-sidebar">
            <ul class="account-sidebar-list">
              <li
                :class="currentPath == '/user/setting/account' ? 'active' : ''"
              >
                <router-link :to="{ path: '/user/setting/account' }">
                  My Account
                </router-link>
              </li>
              <li :class="currentPath == '/user/setting/order' ? 'active' : ''">
                <router-link :to="{ path: '/user/setting/order' }">
                  My Orders
                </router-link>
              </li>
              <li
                :class="currentPath == '/user/setting/address' ? 'active' : ''"
              >
                <router-link :to="{ path: '/user/setting/address' }">
                  My Addresses
                </router-link>
              </li>
              <li>
                <a href="javascript:;" @click="logoutAccount">Sign Out</a>
              </li>
            </ul>
          </div>
        </div>
        <div class="col-sm-12 col-md-8 col-lg-8 pb-30">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { Notify } from "quasar";

import { useUserStore } from "src/stores/user";
const userStore = useUserStore();

import {
  reactive,
  toRefs,
  onBeforeMount,
  onMounted,
  getCurrentInstance,
  defineComponent,
  computed,
} from "vue";

// const Component = defineComponent({});

const { proxy } = getCurrentInstance();

const props = defineProps({});

const data = reactive({
  currentPath: computed(() => proxy.$route.path),
});
const { currentPath } = toRefs(data);

onBeforeMount(() => {});
onMounted(() => {
  console.log(data.currentPath);
});

const logoutAccount = () => {
  userStore
    .Logout()
    .then(() => {
      Notify.create("退出成功");
      proxy.$router.push("/");
    })
    .catch((e) => console.log(e));
};
</script>
<style lang="scss" scoped></style>
